﻿using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using FoosballEye.Model;

namespace FoosballEye.Repository
{
    public class FoosballEyeDbContext : DbContext
    {
        public DbSet<Game> Games { get; set; }
        public DbSet<GameLevel> GameLevel { get; set; }
        public DbSet<GameTeam> GameTeams { get; set; }
        public DbSet<LodzOfficeRoom> LodzOfficeRooms { get; set; }
        public DbSet<Player> Players { get; set; }
        public DbSet<PlayerHistory> PlayerHistories { get; set; }
        public DbSet<LoginHistory> LoginHistories { get; set; }
        public DbSet<SeasonPlayerRanking> SeasonPlayerRankings { get; set; }

        //protected override void OnModelCreating(DbModelBuilder modelBuilder)
        //{
            //modelBuilder.Entity<Security>().ToTable("Securities");
            //modelBuilder.Entity<Stock>().ToTable("Securities_Stock");
            //modelBuilder.Entity<MutualFund>().ToTable("Securities_MutualFund");

            //modelBuilder.Entity<WatchList>()
            //    .HasMany(w => w.Securities).WithMany()
            //    .Map(map => map.ToTable("WatchListSecurity")
            //                    .MapRightKey("SecurityId")
            //                    .MapLeftKey("WatchListId"));
        //}

        //public int DeleteAccounts()
        //{
        //    return Database.ExecuteSqlCommand("DeleteAccounts");
        //}

        //public int DeleteSecuritiesAndExchanges()
        //{
        //    return Database.ExecuteSqlCommand("DeleteSecuritiesAndExchanges");
        //}

        ///// <summary>
        // HACK: Code below creates database model, use olny once at the begining of project
        ///// </summary>
        //public static void CreateDatabaseSchemaFromModel()
        //{
        //    FoosballEyeDbContext dataContext = new FoosballEyeDbContext();
        //    //dataContext.Database.Initialize(true);

        //    IObjectContextAdapter adapter = dataContext;
        //    string script = adapter.ObjectContext.CreateDatabaseScript();
        //    dataContext.Database.ExecuteSqlCommand(script);
        //}

    }
}
